"""
756. 蛇形矩阵
https://www.acwing.com/problem/content/758/
@date 2021年1月11日11:56:00
@author mizzle rain
"""

n, m = list(map(int, input().strip().split()))
res = [[0 for _ in range(m)] for _ in range(n)]

top, bottom, left, right = 0, n-1, 0, m-1

start = 1

while left <= right or top <= bottom:
    if top <= bottom:
        for i in range(left, right+1):
            res[top][i] = start
            start += 1
        top += 1
    if left <= right:
        for i in range(top, bottom + 1):
            res[i][right] = start
            start += 1
        right -= 1
    if top <= bottom:
        for i in range(right, left-1, -1):
            res[bottom][i] = start
            start += 1
        bottom -= 1
    if left <= right:
        for i in range(bottom, top-1, -1):
            res[i][left] = start
            start += 1
        left += 1


for item in res:
    print(" ".join(map(str, item)))
